﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyCs
{
    class Point
    {
        public int x;
        public int y;

        public int num = 0;        
        static Point p=null;
        private Point(int x,int y) {
            this.x = x;
            this.y = y;
            num++;
        }
        static public Point CreatePoint(int x,int y)
        {
            if (p!=null)
            {
                return p;
            }
            else
            {
                p= new Point(x,y);
                return p;
            }           
            
        }
    }

    class Rectangle
    {
        private int a;
        private int b;
        static public int num;
        public Rectangle(int a, int b)
        {
            this.a = a;
            this.b = b;
        }

        private Rectangle() { }

        static public Rectangle CreateRectangel()
        {
            Rectangle rectangle = new Rectangle();
            
            return rectangle;
        }

        public int Area()
        {
            int s = 0;
            s = a * b;
            return s;
        }
        public void SetA(int a)
        {
            this.a = a;
        }
        public void SetB(int b)
        {
            this.b = b;
        }
    }



    class Program
    {
        static void Main(string[] args)
        {
            Rectangle rec=new Rectangle(3,5);
          
            int s=rec.Area();
            Console.WriteLine(s);
            Rectangle.num = 10;
            Console.WriteLine($"num={Rectangle.num}");


            Rectangle rec2 = Rectangle.CreateRectangel();
            rec2.SetA(7);
            rec2.SetB(8);
            Console.WriteLine($"rec2面积是：{rec2.Area()}");

           Point p= Point.CreatePoint(10, 20);
            Console.WriteLine(p.num);
            Point p2=Point.CreatePoint(18, 33);
            Console.WriteLine(p2.num);
            Console.WriteLine($"x={p2.x} y={p2.y}");


            Console.ReadLine();

        }
    }
}
